/**
* AutoSWF - Cody Cushing. March 26, 2009
* Copyright (c) 2009 Cody Cushing
* No use restrictions. Maintain this notice in all versions. 
**/

package com.autoswf.dispatcher
{
	import com.autoswf.core.ILink;
	import com.autoswf.core.Transport;
	
	/**
	 * Mediator object to bubble addEventListener and removeEventListener arguments to a RemoteDispatcher.
	 */
	public class RemoteListener extends Transport
	{
		/** Whether to use the arguments array to add a listener or remove it. */
		public var removeListener:Boolean = false;
		
		
		/**
		 * Constructor
		 * 
		 * @param rest  Arguments matching the parameter signature of addEventListener
		 * [type, listener, useCapture, priority, useWeakReference]
		 */
		public function RemoteListener(...rest)
		{
			_arguments = rest;
		}
		
		
		/** Set arguments and configure this RemoteListener for adding an event listener. */
		public function add(type:String, listener:Function, useCapture:Boolean=false, priority:int=0, useWeakReference:Boolean=false):RemoteListener
		{
			_arguments = arguments;
			return this;
		}
		
		
		/** Set arguments and configure this RemoteListener for removing an event listener. */
		public function remove(type:String, listener:Function, useCapture:Boolean=false):RemoteListener
		{
			_arguments = arguments;
			removeListener = true;
			return this;
		}
		
		
		/**
		 * Method for sending this RemoteListener up the chain.
		 * @param link  Node for sending this Listener up the chain. 
		 */
		public function sendBy(link:ILink):void
		{
			link.sendUp(this);
		}
	}
}